﻿
<?php

	include("php/session.php");
	include("php/error.php");
	include("php/bbcode.php");
	include("dao/CategoriasDAO.class.php");
	include("dao/ConteudoDAO.class.php");
	include("dao/UsuarioDAO.class.php");
	
	set_error_handler("customError");
	
	$idcategoria_get = $_GET['append'];
	$categoria_get = $_GET['match'];
	
	$categoriasdao = new CategoriasDAO();
	$categorias = $categoriasdao->buscar();
	
	$conteudodao = new ConteudoDAO();
	$conteudos = $conteudodao->buscarNews($idcategoria_get);
	
	$usuariodao = new UsuarioDAO();
	
?>


<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Chimera</title>
<link rel="stylesheet" type="text/css" href="css/css.css">
<link rel="stylesheet" type="text/css" href="css/prettify.css">
<script src="js/run_prettify.js"></script>
</head>

<body>
	<main>
    
    	<header>
            <div class="container">
                <a href="inicio.php"><span class="logo"></span></a>
                <input type="text" class="pesquisaTopo" placeholder="Faça sua pesquisa..." />
                <select class="categoriasPesquisa">
                    <?php foreach($categorias as $categoria): ?>
                        <option value="<?= $categoria->getIdCategorias();?>"><?= $categoria->getNome();?></option>
                    <?php endforeach;?>
                </select>
                <span class="logout">
                    <a href="php/logout.php">sair</a>
                </span>
                <span class="sessionNome"><?= $_SESSION['nome'] ?></span>
            </div>
        </header>
      
   	  	<section class="news">
            <div class="subMenuToolbar">
                <div class="container">
                    <h1><?= $categoria_get?></h1>
                    <ul class="subMenu">
                        <li><a href="inicio.php">início</a></li>
                        <li><a href="posts.php?append=<?= $idcategoria_get?>&match=<?= $categoria_get?>">posts</a></li>
                        <li><a href="novo.php?append=<?= $idcategoria_get?>&match=<?= $categoria_get?>">novo</a></li>
                    </ul>
                </div>
            </div>
            <div class="container">
            
                <div class="junteLeft">
                    <h3 class="menuTitulo">Vamos pra outra ?</h3>
                    <ul class="menu">
         
                        <?php foreach($categorias as $categoria): ?>
                        
                            <li>
                                <a href="news.php?append=<?= $categoria->getIdCategorias();?>&match=<?= $categoria->getNome();?>">
									<?= $categoria->getNome();?>
                                </a>
                            </li>
                        
                        <?php endforeach;?>
                    
                    </ul>
                </div>
                
                <div class="junteRight">
                    <h3 class="menuTitulo">Últimas em <?= $categoria_get?></h1>
                    <ul class="posts">
                        
                        <?php foreach ($conteudos as $conteudo): ?>
                                    
                        <?php $usuario = $usuariodao->buscar($conteudo->getFk_idUsuario()); ?>
                        
                            <li class="postsLi">
                                <a href="post.php?append=<?= $conteudo->getIdConteudo();?>&match=<?= $categoria_get?>">
                                    <span class="assuntoUltimas">
                                        <?= $conteudo->getAssunto();?></br>
                                        <span class="autorUltimas">por: <?= $usuario->getNome();?></span>
                                    </span>
                                    <span class="dataUltimas"><?= $conteudo->getData();?></span>
                                </a>
                            </li>
                        
                        <?php endforeach;?>
                        
                    </ul>
                </div>
                
            </div>
        
        </section>
    </main>
</body>
</html>

